<script>
// 删除弹窗
import { defineComponent } from 'vue'
export default defineComponent({
	name: 'deleGroupDialogue'
})
</script>
<script setup>
import { toRaw } from '@vue/reactivity';
import { ref,defineExpose } from 'vue'
import {reqMaterialGroupUpdate} from '@/api'
const dialogVisible = ref(false)
const form = ref({})
const show = (val)=>{
  dialogVisible.value = true;
  form.value = toRaw(val)
}
const handleClose = (done) => {
  dialogVisible.value = false;
}
const onSubmit = async() => {
  const r = await reqMaterialGroupUpdate({
    "delete":[form.value.id]
  })
  console.log(r)
  if (r.msg){
    dialogVisible.value = false;
    console.log('asdasd')
    emits('diaUpdate')
  }
}
defineExpose({
  show
});
const emits = defineEmits(['diaUpdate'])
</script>
<template>
  <el-dialog
    v-model="dialogVisible"
    title="删除分组"
    width="30%"
    :before-close="handleClose"
  >
   <div>
     是否确认删除「{{ form.title }}」分组？
   </div>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="onSubmit"
          >确定</el-button
        >
      </span>
    </template>
  </el-dialog>
</template>
<style scoped>
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
